package com.ott.tool;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.output.XMLOutputter;
public class CreateXmlUtil {

	public void createXML(String name,String filepath,String tomcatPath) throws IOException{
		File file = new File(tomcatPath);
		if(!file.exists()){
			file.mkdir();
		}
		File file2 = new File(tomcatPath+name+".xml");
		if(file2.exists()){
			file2.delete();
		}
		Element root = new Element("Context");
		root.setAttribute("path",name);
		root.setAttribute("docBase",filepath);
		root.setAttribute("debug","0");
		root.setAttribute("privileged","true");
		XMLOutputter XMLOut = new XMLOutputter();
		Document doc = new Document(root);
		FileOutputStream fos = new FileOutputStream(tomcatPath+name+".xml");
		XMLOut.output(doc, fos);
		fos.close();
	}
	
	
	public static void main(String[] args) throws IOException {
		//createXML();
	}
}
